
//
//  SixVC.m
//  yuanjiang
//
//  Created by YuanJiang on 2019/9/19.
//  Copyright © 2019 llbt. All rights reserved.
//

#import "SixVC.h"
#import "YJModel.h"

@interface SixVC ()

@end

@implementation SixVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"归档接档";
    
    YJModel *model = [[YJModel alloc] init];
    model.age = 18;
    model.name = @"佳佳";
    model.other = @"jiang";
    
    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSLog(@"路径%@",filePath);
    NSString *newPath = [filePath stringByAppendingPathComponent:@"/YJModel.data"];
    
    BOOL result = [NSKeyedArchiver archiveRootObject:model toFile:newPath];
    if (result) {
        NSLog(@"归档成功");
    }else{
        NSLog(@"归档失败");
    }
    
    
    
    YJModel *yy = [NSKeyedUnarchiver unarchiveObjectWithFile:newPath];
    NSLog(@"年龄%@\nname:%@",@(yy.age),yy.name);
    
}


@end
